package com.atguigu.observer.demo2;
import java.util.Observable;
import java.util.Observer;

public class QQWebSite implements Observer {
    
    Observable observable;
    private float temperature;
    
    public QQWebSite(Observable observable){
        this.observable = observable;
        this.observable.addObserver(this);
    }

    @Override
    public void update(Observable o, Object arg) {
        if(o instanceof WeatherData){
            WeatherData wd = (WeatherData)o;
            this.temperature = wd.getTemperature();
            display();
        }
    }
    
    public void display(){
        System.out.println("当前温度："+this.temperature+"摄氏度");
    }

}